<template>
  <a-layout id="components-layout-demo-custom-trigger">
    <a-layout-sider v-model="collapsed" :trigger="null" collapsible theme="light">
      <div class="logo" @click="$router.push('/device')">
        <img src="@/assets/logo.png" />
        <h2 v-show="!collapsed">{{ title }}</h2>
      </div>
      <Menu />
    </a-layout-sider>
    <a-layout>
      <a-layout-header style="background: #fff; padding: 0">
        <div class="top-bar">
          <a-icon
            class="trigger"
            :type="collapsed ? 'menu-unfold' : 'menu-fold'"
            @click="() => (collapsed = !collapsed)"
          />
          <a-dropdown>
            <a-avatar>{{ name ? name : 'user' }}</a-avatar>
            <a-menu slot="overlay">
              <a-menu-item @click="logout"
                ><a-icon type="logout" />退出</a-menu-item
              >
            </a-menu>
          </a-dropdown>
        </div>
      </a-layout-header>
      <a-layout-content
        :style="{
          margin: '24px 16px',
          padding: '24px',
          background: '#fff',
          minHeight: '280px',
        }"
      >
        <Nuxt />
      </a-layout-content>
      <!-- <a-layout-footer style="text-align: center">
        {{ title }} ©2020 丹秋集团信息中心
      </a-layout-footer> -->
    </a-layout>
  </a-layout>
</template>
<script>
import Menu from "./menu";
export default {
  components: { Menu },
  head() {
    return { title: this.title };
  },
  data() {
    return {
      collapsed: false,
      title: "统一资源管理平台",
      name:localStorage.getItem('name')
    };
  },
  methods: {
    logout() {
      this.$router.push("/login")
      localStorage.removeItem('token') // 退出登陆 删除token
    },
  },
};
</script>
<style lang="scss">
#components-layout-demo-custom-trigger .trigger {
  font-size: 18px;
  line-height: 64px;
  padding: 0 24px;
  cursor: pointer;
  transition: color 0.3s;
}

#components-layout-demo-custom-trigger .trigger:hover {
  color: #1890ff;
}

#components-layout-demo-custom-trigger .logo {
  height: 32px;
  margin: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  h2 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 0 6px;
    font-size: 16px;
    font-weight: bold;
  }
}
.ant-layout-sider {
  min-height: 100vh;
}
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 24px;
}
</style>